import request from '@/config/axios'

// ERP采购管理-原料采购单主 VO
export interface PurRawMaterialPurchaseOrderVO {
  id: string // ID
  purchaseOrderNo: string // 采购单号码
  supplierId: string // 供应商ID
  supplierName: string // 供应商名称
  purchaseType: string // 采购类型
  isApproved: boolean // 审核
  approver: string // 审核人
  approveTime: Date // 审核时间
  recalculateWidth: boolean // 重新计算幅宽是否按采购宽
  orderDate: Date // 开单日期
  materialType: string // 原料类型
  isAccounted: boolean // 立账
  currency: string // 币别
  exchangeRate: number // 汇率
  quotationUnit: string // 报价单位
  deliveryDate: Date // 交货日期
  basicAmount: number // 基础金额
  discount: number // 折扣
  discountedAmount: number // 折后金额
  taxType: string // 税别
  taxRate: number // 税率
  discountAmount: number // 折扣金额
  taxAmount: number // 税额
  totalWeight: number // 总重量
  totalArea: number // 总面积
  totalVolume: number // 总体积
  deliveryDuration: number // 交货时长
  totalAmount: number // 总金额
}

// ERP采购管理-原料采购单主 API
export const PurRawMaterialPurchaseOrderApi = {
  // 查询ERP采购管理-原料采购单主分页
  getPurRawMaterialPurchaseOrderPage: async (params: any) => {
    return await request.get({ url: `/erp/pur-raw-material-purchase-order/page`, params })
  },

  // 查询ERP采购管理-原料采购单主详情
  getPurRawMaterialPurchaseOrder: async (id: number) => {
    return await request.get({ url: `/erp/pur-raw-material-purchase-order/get?id=` + id })
  },

  // 新增ERP采购管理-原料采购单主
  createPurRawMaterialPurchaseOrder: async (data: PurRawMaterialPurchaseOrderVO) => {
    return await request.post({ url: `/erp/pur-raw-material-purchase-order/create`, data })
  },

  // 修改ERP采购管理-原料采购单主
  updatePurRawMaterialPurchaseOrder: async (data: PurRawMaterialPurchaseOrderVO) => {
    return await request.put({ url: `/erp/pur-raw-material-purchase-order/update`, data })
  },

  // 删除ERP采购管理-原料采购单主
  deletePurRawMaterialPurchaseOrder: async (id: number) => {
    return await request.delete({ url: `/erp/pur-raw-material-purchase-order/delete?id=` + id })
  },

  // 导出ERP采购管理-原料采购单主 Excel
  exportPurRawMaterialPurchaseOrder: async (params) => {
    return await request.download({ url: `/erp/pur-raw-material-purchase-order/export-excel`, params })
  },

// ==================== 子表（ERP采购管理-原料采购单子） ====================

  // 获得ERP采购管理-原料采购单子分页
  getPurRawMaterialPurchaseOrderDetailPage: async (params) => {
    return await request.get({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-order-detail/page`, params })
  },
  // 新增ERP采购管理-原料采购单子
  createPurRawMaterialPurchaseOrderDetail: async (data) => {
    return await request.post({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-order-detail/create`, data })
  },

  // 修改ERP采购管理-原料采购单子
  updatePurRawMaterialPurchaseOrderDetail: async (data) => {
    return await request.put({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-order-detail/update`, data })
  },

  // 删除ERP采购管理-原料采购单子
  deletePurRawMaterialPurchaseOrderDetail: async (id: number) => {
    return await request.delete({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-order-detail/delete?id=` + id })
  },

  // 获得ERP采购管理-原料采购单子
  getPurRawMaterialPurchaseOrderDetail: async (id: number) => {
    return await request.get({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-order-detail/get?id=` + id })
  },

// ==================== 子表（ERP采购管理-原料采购备注） ====================

  // 获得ERP采购管理-原料采购备注分页
  getPurRawMaterialPurchaseRemarksPage: async (params) => {
    return await request.get({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-remarks/page`, params })
  },
  // 新增ERP采购管理-原料采购备注
  createPurRawMaterialPurchaseRemarks: async (data) => {
    return await request.post({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-remarks/create`, data })
  },

  // 修改ERP采购管理-原料采购备注
  updatePurRawMaterialPurchaseRemarks: async (data) => {
    return await request.put({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-remarks/update`, data })
  },

  // 删除ERP采购管理-原料采购备注
  deletePurRawMaterialPurchaseRemarks: async (id: number) => {
    return await request.delete({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-remarks/delete?id=` + id })
  },

  // 获得ERP采购管理-原料采购备注
  getPurRawMaterialPurchaseRemarks: async (id: number) => {
    return await request.get({ url: `/erp/pur-raw-material-purchase-order/pur-raw-material-purchase-remarks/get?id=` + id })
  }
}